<script type="text/javascript">
  //BOOSTER APPS COMMON JS CODE
  window.BoosterApps = window.BoosterApps || {};
  window.BoosterApps.common = window.BoosterApps.common || {};
  window.BoosterApps.common.shop = {
    permanent_domain: '{{ shop.permanent_domain }}',
    currency: {{ shop.currency | json }},
    money_format: {{ shop.money_format | json }},
    id: 56339267733
  };
  {% if customer %}
  window.BoosterApps.common.customer = {
    id: {{ customer.id | json }},
    tags: {{ customer.tags | json }},
    email: {{customer.email | json}},
    accepts_marketing: {{ customer.accepts_marketing | json }},
    first_name: {{ customer.first_name | json }},
    last_name: {{ customer.last_name | json }},
    orders_count: {{ customer.orders_count | json }},
    tags: {{ customer.tags | json }},
    total_spent: {{ customer.total_spent | json }}
  };
  {% endif %}

  window.BoosterApps.common.template = '{{ template | split: "." | first }}';
  window.BoosterApps.common.cart = {% if cart.item_count > 0 %}{{ cart | json }}{% else %}{}{% endif %};
  window.BoosterApps.common.vapid_public_key = "BJuXCmrtTK335SuczdNVYrGVtP_WXn4jImChm49st7K7z7e8gxSZUKk4DhUpk8j2Xpiw5G4-ylNbMKLlKkUEU98=";
  window.BoosterApps.global_config = {{shop.metafields.ba_global.config | json}};

  {% if product %}
    if (window.BoosterApps.common.template == 'product'){
      window.BoosterApps.common.product = {
        id: {{product.id}}, price: {{product.price}}, handle: {{product.handle | json}}, tags: {{ product.tags | json}},
        available: {{product.available}}, title: {{product.title | json}}, variants: {{product.variants | json}}
      };
    }
  {% endif %}

    window.BoosterApps.loy_config = {{shop.metafields.ba_loy.config | json}};
    window.BoosterApps.loy_config.api_endpoint = "/apps/ba-loy";
    window.BoosterApps.loy_config.domain_name = "loyalty.rivo.io";




</script>


<script type="text/javascript">
  

  //Global snippet for Booster Apps
  //this is updated automatically - do not edit manually.

  function loadScript(src, defer, done) {
    var js = document.createElement('script');
    js.src = src;
    js.defer = defer;
    js.onload = function(){done();};
    js.onerror = function(){
      done(new Error('Failed to load script ' + src));
    };
    document.head.appendChild(js);
  }

  function browserSupportsAllFeatures() {
    return window.Promise && window.fetch && window.Symbol;
  }

  if (browserSupportsAllFeatures()) {
    main();
  } else {
    loadScript('https://polyfill.io/v3/polyfill.min.js?features=Promise,fetch', true, main);
  }

  function loadAppScripts(){
      loadScript(window.BoosterApps.global_config.asset_urls.loy.init_js, true, function(){});



  }

  function main(err) {
    //isolate the scope
    loadScript(window.BoosterApps.global_config.asset_urls.global.helper_js, false, loadAppScripts);
  }
</script>
